package com.ssy.lingxi.purchase.controller.purchase;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.purchase.api.dto.request.*;
import com.ssy.lingxi.purchase.api.dto.request.purchase.*;
import com.ssy.lingxi.purchase.api.dto.response.BiddingExternalWorkStateEnumResponse;
import com.ssy.lingxi.purchase.api.dto.response.purchase.*;
import com.ssy.lingxi.purchase.service.QuotedPriceService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 采购能力-采购报价
 * @author wrc
 * @date 2021/1/9
 */
@RestController
@RequestMapping("/purchase/quoted/price")
public class QuotedPriceController  extends BaseController {

    @Resource
    QuotedPriceService quotedPriceService;

    /**
     *采购需求单查询
     */
    @GetMapping("/purchase/inquiry/list")
    public Wrapper<PageData<PurchaseInquiryListResponse>> purchaseInquiryList(HttpServletRequest httpServletRequest, PurchaseInquiryListRequest request) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.purchaseInquiryList(request,sysUser);
    }

    /**
     * 需求单报价 - 采购需求单查询 - 采购需求单详情
     */
    @GetMapping("/purchase/inquiry/details")
    public Wrapper<PurchaseInquiryDetailsResponse> purchaseInquiryDetails(BaseDetailsRequest request, HttpServletRequest httpServletRequest ) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.purchaseInquiryDetails(request,sysUser);
    }

    /**
     * 采购询价-采购物料-分页查询
     */
    @GetMapping("/productlist/list")
    public Wrapper<PageData<PurchaseInquiryProductRequest>> purchaseInquiryProductlist(BaseDetailsRequest request) {
        return quotedPriceService.purchaseInquiryProductlist(request);
    }

    /**
     * 新增报价单
     */
    @PostMapping("/add")
    public Wrapper quotedPriceAdd(@Validated @RequestBody QuotedPriceAddRequest request, HttpServletRequest httpServletRequest ) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPriceAdd(request,sysUser);
    }

    /**
     *修改报价单
     */
    @PostMapping("/update")
    public Wrapper quotedPriceUpdate(@Validated @RequestBody QuotedPriceUpdateRequest request, HttpServletRequest httpServletRequest ) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPriceUpdate(request,sysUser);
    }

    /**
     *删除报价单
     */
    @PostMapping("/delete")
    public Wrapper quotedPriceDelete(@Validated  @RequestBody BaseRequest request, HttpServletRequest httpServletRequest ) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPriceDelete(request,sysUser);
    }

    /**
     *批量删除报价单
     */
    @PostMapping("/delete/batch")
    public Wrapper quotedPriceDeleteBatch(@Validated  @RequestBody BaseAllRequest request, HttpServletRequest httpServletRequest ) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPriceDeleteBatch(request,sysUser);
    }

    /**
     *报价单列表查询
     */
    @GetMapping("/list")
    public Wrapper<PageData<QuotedPriceListResponse>> quotedPriceList(QuotedPriceListRequest request, HttpServletRequest httpServletRequest ) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPriceList(request,sysUser);
    }

    /**
     * 报价单详情
     */
    @GetMapping("/details")
    public Wrapper<QuotedPriceDetailsResponse> quotedPriceDetails(BaseDetailsRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPriceDetails(request, sysUser);
    }

    /**
     *待新增采购报价单
     */
    @GetMapping("/add/list")
    public Wrapper<PageData<QuotedPriceListResponse>> quotedPriceAddList(QuotedPriceListRequest request,HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPriceAddList(request,sysUser);
    }

    /**
     *提交审核采购报价单
     */
    @PostMapping("/submit")
    public Wrapper quotedPriceExamine(@Validated  @RequestBody BaseRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPriceExamine(request,sysUser);
    }

    /**
     *提交审核采购报价单批量
     */
    @PostMapping("/submit/batch")
    public Wrapper quotedPriceExamineBatch(@Validated  @RequestBody BaseAllRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPriceExamineBatch(request,sysUser);
    }

    /**
     *待审核报价单(一级)
     */
    @GetMapping("/stay/examine/list1")
    public Wrapper<PageData<QuotedPriceListResponse>> quotedPricestayExamineList1(QuotedPriceListRequest request,HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPricestayExamineList1(request,sysUser);
    }

    /**
     *提交审核采购报价单(一级)
     */
    @PostMapping("/examine1")
    public Wrapper quotedPriceExamine1(@Validated  @RequestBody BaseExamineRequest request,HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPriceExamine1(request,sysUser);
    }

    /**
     *提交审核采购报价单批量(一级)
     */
    @PostMapping("/examine1/batch")
    public Wrapper quotedPriceExamine1Batch(@Validated  @RequestBody BaseAllRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPriceExamine1Batch(request,sysUser);
    }

    /**
     *待审核报价单(二级)
     */
    @GetMapping("/stay/examine/list2")
    public Wrapper<PageData<QuotedPriceListResponse>> quotedPricestayExamineList2(QuotedPriceListRequest request,HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPricestayExamineList2(request,sysUser);
    }

    /**
     *提交审核采购报价单(二级)
     */
    @PostMapping("/examine2")
    public Wrapper quotedPriceExamine2(@Validated  @RequestBody BaseExamineRequest request,HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPriceExamine2(request,sysUser);
    }

    /**
     *提交审核采购报价单批量(二级)
     */
    @PostMapping("/examine2/batch")
    public Wrapper quotedPriceExamine2Batch(@Validated  @RequestBody BaseAllRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPriceExamine2Batch(request,sysUser);
    }

    /**
     *待提交报价单
     */
    @GetMapping("/stay/commit/list")
    public Wrapper<PageData<QuotedPriceListResponse>> quotedPricestayStayCommitList(QuotedPriceListRequest request,HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPricestayStayCommitList(request,sysUser);
    }

    /**
     *提交报价单
     */
    @PostMapping("/stay/commit")
    public Wrapper quotedPriceStayCommit(@Validated  @RequestBody BaseRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPriceStayCommit(request,sysUser);
    }

    /**
     *提交报价单批量
     */
    @PostMapping("/stay/commit/batch")
    public Wrapper quotedPriceStayCommitBatch(@Validated  @RequestBody BaseAllRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.quotedPriceStayCommitBatch(request,sysUser);
    }

    /**
     * 采购合同-采购物料-分页查询
     */
    @GetMapping("/productlist/list/contract")
    public Wrapper<PageData<QuotedPriceProductResponse>> purchaseInquiryProductlistContract(@Validated ContractDetailsRequest request) {
        return quotedPriceService.purchaseInquiryProductlistContract(request);
    }

    /**
     *平台后台报价列表查询
     */
    @GetMapping("/platform/list")
    public Wrapper<PageData<QuotedPriceListResponse>> platformQuotedPriceList(QuotedPriceListRequest request, HttpServletRequest httpServletRequest ) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.platformQuotedPriceList(request,sysUser);
    }

    /**
     *平台后台报价单详情查询
     */
    @GetMapping("/platform/details")
    public Wrapper<QuotedPriceDetailsResponse> platformQuotedPriceDetails(BaseDetailsRequest request, HttpServletRequest httpServletRequest ) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.platformQuotedPriceDetails(request,sysUser);
    }

    /**
     *报价单详情-物料详情列表分页查询
     */
    @GetMapping("/materiel/detailed")
    public Wrapper<PageData<QuotedPriceProductResponse>> materielDetailed(@Valid MaterielDetailedRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.materielDetailed(request,sysUser);
    }

    /**
     *平台后台-报价详情
     */
    @GetMapping("/platform/detailed")
    public Wrapper<ConfirmQuotedPriceResponse> platformDetails(@Valid  ConfirmQuotedPriceDetailsRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quotedPriceService.platformDetails(request,sysUser);
    }

    /**
     * 获取采购报价单内部流程状态
     */
    @GetMapping("/interior/status")
    public Wrapper<List<BiddingExternalWorkStateEnumResponse>> interiorStatus() {
        return quotedPriceService.interiorStatus();
    }
}
